package com.example.demo.vo.webvo

import com.example.demo.dbmodels.TMenu
import io.swagger.annotations.ApiModelProperty
import java.time.LocalDateTime

class MenuVo {
    @ApiModelProperty("菜单id")
    var id: Int? = null

    @ApiModelProperty("父菜单id")
    var parent_id: Int? = null

    @ApiModelProperty("菜单类型")
    var type: String? = null

    @ApiModelProperty("菜单标签")
    var name: String? = null

    @ApiModelProperty("菜单路径")
    var url: String? = null

    @ApiModelProperty("扩展名")
    var ext: String? = null

    @ApiModelProperty("菜单图标")
    var icon: String? = null

    @ApiModelProperty("组件路径")
    var component: String? = null

    @ApiModelProperty("排序号码")
    var sort: Int? = null

    @ApiModelProperty("层次号码")
    var level: Int? = null

    @ApiModelProperty("是否用iframe显示整个页面")
    var is_iframe: Boolean? = null

    @ApiModelProperty("版本号")
    var version: Float? = null

    @ApiModelProperty("状态1=有效，0=无效")
    var status: Boolean? = null

    @ApiModelProperty("备注")
    var remark: String? = null

    @ApiModelProperty("更新时间")
    var update_time: LocalDateTime? = null

    @ApiModelProperty("更新人")
    var update_by: Int? = null

    @ApiModelProperty("MenuVo")
    var menuChird: List<MenuVo>? = null


    fun getVo(table: TMenu): MenuVo {
        table.let {
            val data = MenuVo()
            data.id = it.id
            data.component = it.component
            data.ext = it.ext
            data.icon = it.icon
            data.is_iframe = it.is_iframe
            data.level = it.level
            data.name = it.name
            data.parent_id = it.parent_id
            data.remark = it.remark
            data.sort = it.sort
            data.status = it.status
            data.type = it.type
            data.update_by = it.update_by
            data.update_time = it.update_time
            data.url = it.url
            data.version = it.version
            return data
        }
    }


    fun getListVo(table: List<TMenu>): List<MenuVo> {
        table.let {
            val menuVos = mutableListOf<MenuVo>()
            table.forEach {
                val data = MenuVo()
                data.id = it.id
                data.component = it.component
                data.ext = it.ext
                data.icon = it.icon
                data.is_iframe = it.is_iframe
                data.level = it.level
                data.name = it.name
                data.parent_id = it.parent_id
                data.remark = it.remark
                data.sort = it.sort
                data.status = it.status
                data.type = it.type
                data.update_by = it.update_by
                data.update_time = it.update_time
                data.url = it.url
                data.version = it.version
                menuVos.add(data)
            }
            return menuVos
        }
    }

}